ActiveReports Developer 7
Add Field Expressions
Support Forum
ActiveReports Developer 7 > ActiveReports Developer Guide > How To > Section Report How To > Work with Report Controls > Add Field Expressions

Glossary Item Box

In a section report, expressions can be used in the DataField property to specify textbox output in a report, such as date/time, mathematical calculations or conditional values. All field expressions used in the DataField property begin with the equals sign (=).

Using Field Expressions

ShowTo use a mathematical expression

Set the DataField property of a textbox control to a mathematical calculation.

Example:

=UnitPrice+5

=Quantity-5

=Quantity*UnitPrice

=UnitPrice/QuantityPerUnit

ShowTo use a substring

Set the DataField property of a textbox control to the required substring. While setting up grouping, change the GroupHeader's DataField property to the same substring.

Example:

=ProductName.Substring(0, 1)

ShowTo use date/time

Set the DataField property of a textbox control similar to the following expression to display date/time values.

Example:

=System.DateTime.Now.ToString()

ShowTo create a conditional value

Set the DataField property of a textbox control to the conditional statement as desired.

Example:

=(UnitsInStock > 0)?"In Stock":"Backorder"

ShowTo concatenate fields

Set the DataField property of a textbox control similar to the following expression to display concatenated fields.

Example:

="There are " + UnitsInStock + " units of " + ProductName + " in stock."

=TitleOfCourtesy + " " + FirstName + " " + LastName

Note: ActiveReports Developer automatically handles null values, replacing them with an empty string.

ShowTo round a calculation

Set the DataField Property of a textbox control like the following example.

Example:

=(double)System.Math.Round(UnitsInStock/10)

ShowTo use modular division

Set the DataField property of a textbox control like the following example to get the remainder (2 in this case).

Example: =22%(5)

ShowTo replace a null value

Set the DataField property of a textbox control like the following example to replace null with your own value.

Example:

=(UnitsInStock == System.DBNull.Value) ? "No Units In Stock" : UnitsInStock

©2014. ComponentOne, a division of GrapeCity. All rights reserved.